# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=backcookie
pkgver=51.6dabc38
pkgrel=5
groups=('blackarch' 'blackarch-backdoor' 'blackarch-webapp')
pkgdesc='Small backdoor using cookie.'
arch=('any')
depends=('python2' 'python2-requests')
makedepends=('git')
url='https://github.com/mrjopino/backcookie'
license=('custom:unknown')
source=("git+https://github.com/mrjopino/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/opt/$pkgname"
	install -dm 755 "$pkgdir/usr/bin/"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  cp -a --no-preserve=ownership * "$pkgdir/opt/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /opt/$pkgname
exec python2 $pkgname.py "\$@"
EOF

	chmod +x "$pkgdir/usr/bin/$pkgname"
}

